package com.wd.tech.adaptert;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.wd.tech.R;
import com.wd.tech.bean.HomePageForDetailsBean;

import java.util.List;

/**
 * @author 时文豪
 * @description:
 * @date :2020/7/6 17:14
 */
public class HomeOneAdaptert extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    Context context;
    List<HomePageForDetailsBean.ResultBean.InformationListBean> list;

    public HomeOneAdaptert(Context context, List<HomePageForDetailsBean.ResultBean.InformationListBean> list) {
        this.context = context;
        this.list = list;
    }



    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = View.inflate(context, R.layout.home_one_item, null);
        return new HomeOne(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        Glide.with(context).load(list.get(position).getThumbnail())
                .apply(RequestOptions.bitmapTransform(new RoundedCorners(20)))
                .into(((HomeOne) holder).one_iv);
        ((HomeOne) holder).one_txt.setText(list.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class HomeOne extends RecyclerView.ViewHolder {

        private final ImageView one_iv;
        private final TextView one_txt;

        public HomeOne(@NonNull View itemView) {
            super(itemView);
            one_iv = itemView.findViewById(R.id.home_one_iv);
            one_txt = itemView.findViewById(R.id.home_one_txt);
        }
    }
}
